
function isValidPhone(str) {
    let par = /^1[0-9]{10}$/;
    return par.test(str);
}

function hasClass(el,name) {
    let classes = el.className;
    if(classes.trim() === '') {
        return false;
    }
    let regex = new RegExp('(^|\\s+)'+name+'(\\s+|$)');
    let res = classes.match(regex);
    if(!res) {
        return false;
    }
    return regex;
}

function removeClass(el, name) {
    let regex = hasClass(el, name);
    if(!regex) {
        return;
    }
    el.className = el.className.replace(regex, '');
    console.log(el.className);
}

function addClass(el,name) {
    let regex = hasClass(el, name);
    if(regex) {
        return;
    }
    el.className = el.className+' '+name;
}


module.exports = {
    isValidPhone,
    hasClass,
    removeClass,
    addClass
}